package aceona.api.weibo.sina;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class SinaScannerServlet extends HttpServlet {

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		doPost(req, resp);
	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		resp.setCharacterEncoding("UTF-8");
		PrintWriter writer = resp.getWriter();
		Enumeration<String> enums = req.getParameterNames();
		Map<String,String> params = new HashMap<String, String>();
		while(enums.hasMoreElements()){
			String param = enums.nextElement();
			params.put(param, req.getParameter(param));
			System.out.println("key: "+param+" "+req.getParameter(param));
		}
		
		SinaScanner sina = new SinaScanner();
//		sina.scan(params);//开始扫描
		
		writer.append("success");
		writer.flush();
		writer.close();
	}

}
